package com.cictec.cloud.app.appserver.rest;

import com.cictec.cloud.app.appserver.feign.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author :zoboy
 * @Description:
 * @ Date: Created in 2020-05-09 13:33
 */
@RestController
@RequestMapping("/app/feign/file")
public class DcFeignFileController {

    @Autowired
    UploadService uploadService;


    @PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String handleFileUpload(@RequestParam(value = "file") MultipartFile file) {
//        File dest = new File("E:\\uploadFiles\\dc\\"+file.getOriginalFilename());
//        try {
//            file.transferTo(dest);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        return uploadService.handleFileUpload(file);
    }
}
